﻿using Estsh.Core.IServices;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Services;
using Estsh.Core.Util;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using System.Collections;
using System.Text.Json;

namespace Estsh.Core.Web.Plugin.Wms.Controllers
{
    [Route("wms/[controller]")]
    [ApiController]
    public class PluginTestApiController : Controller
    {
        private IAccountService service;
        private readonly IMemoryCache memoryCache;

        public PluginTestApiController(IAccountService _service, IMemoryCache _memoryCache)
        {
            this.service = _service;
            this.memoryCache = _memoryCache;
        }
        [HttpGet("Index0")]
        public IActionResult Index0(string a,string b)
        {
            return View();
        }

        [HttpPost("Index1")]
        public IActionResult Index1(string a, string b)
        {
            return View();
        }


        [HttpPost("Index2")]
        public IActionResult Index2([FromForm] string a, [FromForm] string b, [FromForm] string c)
        {
            return View();
        }

        [HttpPost("Index3")]
        public IActionResult Index3([FromForm] SysEmp user,[FromForm] Pager pager)
        {
            return View();
        }

        [HttpPost("Index4")]
        public IActionResult Index4(RequestBody requestBody)
        {
            return View();
        }

        [HttpPost("SetMemoryCache")]
        public IActionResult SetMemoryCache()
        {
            SysEmp emp = new SysEmp();
            emp.EmpId = 11;
            emp.EmpNo = "admin";
            emp.EmpName = "admin Name";
            memoryCache.Set("user", emp);
            return Json(emp);
        }

        [HttpPost("GetMemoryCache")]
        public IActionResult GetMemoryCache()
        {
            SysEmp emp = (SysEmp) memoryCache.Get("user");
            return Json(emp);
        }


    }
}
